Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
What does "a.call.apply(a.bind, arguments)" mean?

Just because of curiosity I wanted to make a bounded function with this particular approach :

var fn = function(a, b, c) {
    return a.call.apply(a.bind, arguments)
}

var boundFn = function(a, b, c) {
    fn.apply(null, arguments)
}

function unboundedFn() {
    console.log(this, arguments)
}

var boundedFn = boundFn(unboundedFn, x, y);

So I'm trying to understand what a.call.apply(a.bind, arguments) do exactly ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If You have a function like this:

function unboundedFn() {
    console.log(this, arguments)
}

You can use unboundedFn.call(thisObj, arg1, arg2) or unboundedFn.apply(thisObj, [arg1, arg2]) to run it, but changing what this means inside. Both call and apply do the same, and only difference is way of passing arguments.

Becouse call, apply and also bind are methods, you can run for example unboundedFn.call.call.call.call.apply.apply.apply.apply(), but it doesn't seem to have to much sense.

In your example return a.call.apply(a.bind, arguments) is equal to return a.bind.call(...arguments), which is equal to a.bind(...arguments.slice(1)), so whole fn function can be simplified to:

function fn(a,b,...args){
   return a.bind(b, ...args);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!